﻿using System.Web.Mvc;
using Pixster.Models;

public static class UrlHelperExtension
{
    public static string Home(this UrlHelper helper)
    {
        return helper.Content("~/");
    }

    public static string SignUp(this UrlHelper helper)
    {
        return helper.RouteUrl("Signup");
    }

    public static string Directory(this UrlHelper helper, string directoryName)
    {
        return helper.RouteUrl("Directories", new { directory = directoryName });
    }

    public static string Album(this UrlHelper helper, string directoryName, string album)
    {
        return helper.RouteUrl("Albums", new { directory = directoryName, albumName = album });
    }

    public static string Photo(this UrlHelper helper, string directoryName, string album, string photo)
    {
        return helper.RouteUrl("Photos", new { directory = directoryName, albumName = album, photoName = photo });
    }

    public static string NextPhoto(this UrlHelper helper, PixsterViewModel viewModel)
    {
        return viewModel.NextPhoto == null
                   ? Album(helper, viewModel.CurrentDirectory.SeoName, viewModel.CurrentAlbum.SeoName)
                   : Photo(helper, viewModel.CurrentDirectory.SeoName, viewModel.CurrentAlbum.SeoName, viewModel.NextPhoto.SeoName);
    }

    public static string PreviousPhoto(this UrlHelper helper, PixsterViewModel viewModel)
    {
        return viewModel.PreviousPhoto == null
                   ? Album(helper, viewModel.CurrentDirectory.SeoName, viewModel.CurrentAlbum.SeoName)
                   : Photo(helper, viewModel.CurrentDirectory.SeoName, viewModel.CurrentAlbum.SeoName, viewModel.PreviousPhoto.SeoName);
    }

    public static string Update(this UrlHelper helper)
    {
        return helper.RouteUrl("Update");
    }

    public static string Submit(this UrlHelper helper)
    {
        return helper.RouteUrl("Submit");
    }
}